#!/bin/bash

# A dwm Automatically install base components script
# Power: acpid tlp xfce4-power-manager
# CPU: thermald cpupower
# Audio: alsa-utils pulseaudio 	pulseaudio-alsa pulseaudio-bluetooth pulseaudio-equalizer
# pulsemixer pasystray pavucontrol
# Images: feh
# CUPS(print): cups-pdf cups ghostscript gsfonts {gutenprint foomatic-db-gutenprint-ppds(drive)}
# {CUPS GUI: print-manager(KDE) system-config-printer}
# CUPS Server: http://localhost:631/
# TODO :Email
# Evan Zhai <EvanZhai@outlook.con>
# GNU GPLv3

function installation_components() {
    sudo pacman -S iwd dhcpcd neovim base-devel git xorg-server xorg-apps xorg-xinit \
        acpid thermald cpupower tlp xfce4-power-manager alsa-utils pulseaudio \
        pulseaudio-alsa pulseaudio-bluetooth pulseaudio-equalizer pulsemixer \
        pasystray pavucontrol feh yay picom cups-pdf cups avahi print-manager \
        fcitx5-im fcitx5-chinese-addons fcitx5-configtool libime v2raya ranger
}

installation_components

function enable_service() {
    sudo systemctl enable iwd.service && sudo systemctl start iwd.service \
    sudo systemctl enable dhcpcd.service && sudo systemctl start dhcpcd.service \
    sudo systemctl enable acpid.service && sudo systemctl start acpid.service \
    sudo systemctl enable cpupower.service && sudo systemctl start cpupower.service \
    sudo systemctl enable tlp.service && sudo systemctl start tlp.service \
    sudo systemctl enable cups.service && sudo systemctl start cups.service \
    sudo systemctl enable avahi-daemon.service && sudo systemctl enable avahi-daemon.service \
    sudo systemctl disable systemd-resolved.service
}

enable_service

function installation_fonts() {
    sudo pacman -S ttf-dejavu wqy-zenhei wqy-microhei noto-fonts-emoji noto-fonts noto-fonts-cjk \
        adobe-source-code-pro-fonts adobe-source-han-sans-otc-fonts adobe-source-han-serif-otc-fonts \
        wqy-microhei-lite adobe-source-han-serif-cn-fonts adobe-source-han-serif-tw-fonts \
        adobe-source-han-sans-cn-fonts adobe-source-han-sans-tw-fonts adobe-source-han-sans-jp-fonts \
        adobe-source-han-sans-kr-fonts ttf-baekmuk nerd-fonts-complete
}

installation_fonts

function _startx() {
    echo >> ~/.bash_profile << EOF
    if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
        exec startx
    fi
EOF
}

_startx